package com.preference.test;

import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
import android.app.ActivityManager.RunningTaskInfo;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.preference.PreferenceScreen;

public class FlightPreferenceActivity extends PreferenceActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.layout.lp);
		PreferenceScreen pfs = getPreferenceScreen();
		// com.preference.test.My
		ListPreference lpf = (ListPreference) pfs.getPreference(0);
		System.out.println(lpf.getValue());
		PreferenceManager manager = getPreferenceManager();
		// 根据android:key中指定的名称（相当于id）来获取首选项
		ListPreference listPreference = (ListPreference) manager.findPreference("selected_flight_sort_option");
		System.out.println("存储的值为" + listPreference.getValue());

		ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
		List<RunningAppProcessInfo> rais=am.getRunningAppProcesses();
		for(int i=0;i<rais.size();i++){
			System.out.println(rais.get(i).processName);
			for(String str:rais.get(i).pkgList){
				System.out.println("     "+str);
			}
		}
		System.out.println("\n\n");
		List<RunningTaskInfo> rtis=am.getRunningTasks(100);
		for(int i=0;i<rtis.size();i++){
			System.out.println(rtis.get(i).description);
		}
	}
}